﻿#-*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name:        while circulation
# Purpose:     study while syntax
#
# Author:      SUMMVING
# Email:       summving@gmail.com
#
# Created:     2013/08/15  19:47
# Copyright:   (c) SUMMVING 2013
# Licence:     GPLv3
#-------------------------------------------------------------------------------

"""使用while必须要有退出条件"""
while 1:                       #此时会判断后面的语句，如果为1(True),则继续执行
      print 'hi,there'         #此时已经进入死循环
      str = raw_input("please input t to quit:")
                               #等待键盘输入
      if str == "t":
         break                 #若输入字符为t，则退出
print '----'

"""回车退出,while嵌套"""
h =" "                         #设置h等于空字符串
while h != "t":                #当h不等于t时继续执行
     print "I'm here"
     h = raw_input("in put t to quit:")
     if not h:                 #如果输入为空（直接回车）
        break                  #一样可以退出
     if h == "b":              #若输入 b ，继续执行，不打印one more time
        continue
     print "one more time~~~~" #若输入非b，非t，非空，则继续运行并打印one more time
else:                          #若输入t正常退出，则打印ending....
     print "ending.......:)"

